/**
 * 获取电梯数据
 * @param {[HTMLElement]} elements
 */
export default function getElevatorData(elements) {
    function getElementTop(element) {
        let actualTop = element.offsetTop;
        let current = element.offsetParent;
        while (current !== null) {
            actualTop += current.offsetTop;
            current = current.offsetParent;
        }
        return actualTop;
    }
    return Object.values(elements).map(element => ({
        title: element.title,
        toScroll: getElementTop(element),
    }));
}
